<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>编辑住院治疗情况从表</title>
	<#include "/common/resource.ftl">
	<script type="text/javascript">
		$(function () {
			<#if (params.healthId)??>
				$.ajaxRequest({
					url: '${params.contextPath}/web/elderHospitalization/query.json',
					data: {elderHealthId: "${params.healthId}"},
					success: function (data) {
						if (!data.success) {
							$.message(data.message);
							return;
						}
						var record = data.data;
                        // 获取本人住院史
                        var personHospitalizationList = record.personHospitalizationList;
                        // 获取家庭住院史
                        var familyHospitalizationList = record.familyHospitalizationList;
                        for (var i = 0; i < personHospitalizationList.length; i++) {
                            var row = personHospitalizationList[i];
                            $("input[name='hospitalHistory1Start']:eq("+i+")").val(row.hospitalHistory1StartStr);
                            $("input[name='hospitalHistory1End']:eq("+i+")").val(row.hospitalHistory1EndStr);
                            $("input[name='hospitalHistory1Reason']:eq("+i+")").val(row.hospitalHistory1Reason);
                            $("input[name='hospitalHistory1Orgname']:eq("+i+")").val(row.hospitalHistory1Orgname);
                            $("input[name='hospitalHistory1Number']:eq("+i+")").val(row.hospitalHistory1Number);
                        }
                        for (var i = 2; i < familyHospitalizationList.length + 2; i++) {
                            var row = familyHospitalizationList[i - 2];
                            $("input[name='hospitalHistory1Start']:eq("+i+")").val(row.hospitalHistory1StartStr);
                            $("input[name='hospitalHistory1End']:eq("+i+")").val(row.hospitalHistory1EndStr);
                            $("input[name='hospitalHistory1Reason']:eq("+i+")").val(row.hospitalHistory1Reason);
                            $("input[name='hospitalHistory1Orgname']:eq("+i+")").val(row.hospitalHistory1Orgname);
                            $("input[name='hospitalHistory1Number']:eq("+i+")").val(row.hospitalHistory1Number);
                        }
                        var form = layui.form;
                        form.render();
					}
				});
			</#if>
		});
	</script>
    <link rel="stylesheet" href="${params.contextPath}/static/plug/layui/css/layui.css">
</head>
<body>
	<div class="ui-form">
        <#if (params.healthId)??>
		<form class="layui-form ajax-form" action="${params.contextPath}/web/elderHospitalization/<#if (params.id)??>modify<#else>save</#if>.json" method="post">
			<input type="hidden" name="elderHealthId" value="${params.healthId}" />
            <div class="layui-card">
                <div class="layui-card-header">住院史</div>
                <div class="layui-card-body">
                    <table style="width: 100%; border: #DDDDDD; text-align: left;" border="1" cellpadding="0" cellspacing="0">
                        <tr>
                            <td>
                                <div class="layui-form-item">
                                    <input type="hidden" name="type" value="1"/>
                                    <input type="text" name="hospitalHistory1Start" placeholder="入院日期" class="layui-input ui-date {required:true}" readonly/>
                                </div>
                            </td>
                            <td>
                                <div class="layui-form-item">
                                    <input type="text" name="hospitalHistory1End" placeholder="出院日期" class="layui-input ui-date {required:true}" readonly/>
                                </div>
                            </td>
                            <td>
                                <div class="layui-form-item">
                                    <input type="text" name="hospitalHistory1Reason" placeholder="住院原因" class="layui-input"/>
                                </div>
                            </td>
                            <td>
                                <div class="layui-form-item">
                                    <input type="text" name="hospitalHistory1Orgname" placeholder="住院机构名称" class="layui-input"/>
                                </div>
                            </td>
                            <td>
                                <div class="layui-form-item">
                                    <input type="text" name="hospitalHistory1Number" placeholder="病案号" class="layui-input"/>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <div class="layui-form-item">
                                    <input type="hidden" name="type" value="1"/>
                                    <input type="text" name="hospitalHistory1Start" placeholder="入院日期" class="layui-input ui-date {required:true}" readonly/>
                                </div>
                            </td>
                            <td>
                                <div class="layui-form-item">
                                    <input type="text" name="hospitalHistory1End" placeholder="出院日期" class="layui-input ui-date {required:true}" readonly/>
                                </div>
                            </td>
                            <td>
                                <div class="layui-form-item">
                                    <input type="text" name="hospitalHistory1Reason" placeholder="住院原因" class="layui-input"/>
                                </div>
                            </td>
                            <td>
                                <div class="layui-form-item">
                                    <input type="text" name="hospitalHistory1Orgname" placeholder="住院机构名称" class="layui-input"/>
                                </div>
                            </td>
                            <td>
                                <div class="layui-form-item">
                                    <input type="text" name="hospitalHistory1Number" placeholder="病案号" class="layui-input"/>
                                </div>
                            </td>
                        </tr>
                    </table>
                </div>
            </div>
            <div class="layui-card">
                <div class="layui-card-header">家庭病史</div>
                <div class="layui-card-body">
                    <table style="width: 100%; border: #DDDDDD; text-align: left;" border="1" cellpadding="0" cellspacing="0">
                        <tr>
                            <td>
                                <div class="layui-form-item">
                                    <input type="hidden" name="type" value="2"/>
                                    <input type="text" name="hospitalHistory1Start" placeholder="入院日期" class="layui-input ui-date {required:true}" readonly/>
                                </div>
                            </td>
                            <td>
                                <div class="layui-form-item">
                                    <input type="text" name="hospitalHistory1End" placeholder="出院日期" class="layui-input ui-date {required:true}" readonly/>
                                </div>
                            </td>
                            <td>
                                <div class="layui-form-item">
                                    <input type="text" name="hospitalHistory1Reason" placeholder="住院原因" class="layui-input"/>
                                </div>
                            </td>
                            <td>
                                <div class="layui-form-item">
                                    <input type="text" name="hospitalHistory1Orgname" placeholder="住院机构名称" class="layui-input"/>
                                </div>
                            </td>
                            <td>
                                <div class="layui-form-item">
                                    <input type="text" name="hospitalHistory1Number" placeholder="病案号" class="layui-input"/>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <div class="layui-form-item">
                                    <input type="hidden" name="type" value="2"/>
                                    <input type="text" name="hospitalHistory1Start" placeholder="入院日期" class="layui-input ui-date {required:true}" readonly/>
                                </div>
                            </td>
                            <td>
                                <div class="layui-form-item">
                                    <input type="text" name="hospitalHistory1End" placeholder="出院日期" class="layui-input ui-date {required:true}" readonly/>
                                </div>
                            </td>
                            <td>
                                <div class="layui-form-item">
                                    <input type="text" name="hospitalHistory1Reason" placeholder="住院原因" class="layui-input"/>
                                </div>
                            </td>
                            <td>
                                <div class="layui-form-item">
                                    <input type="text" name="hospitalHistory1Orgname" placeholder="住院机构名称" class="layui-input"/>
                                </div>
                            </td>
                            <td>
                                <div class="layui-form-item">
                                    <input type="text" name="hospitalHistory1Number" placeholder="病案号" class="layui-input"/>
                                </div>
                            </td>
                        </tr>
                    </table>
                </div>
            </div>
			<div class="layui-form-item">
				<div class="layui-input-block">
					<input type="submit" value="保存" class="layui-btn" />
				</div>
			</div>
		</form>
        <#else>
            请先保存老人健康基本信息!
        </#if>
    </div>
</body>
<script src="${params.contextPath}/static/plug/layui/layui.all.js"></script>
<script>
    $(function () {
        var form = layui.form;
        form.render();
    })
</script>
</html>
